<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<c:set var="serviceurl" value="${ctx}/pro/asset" />

<div class="rap-page-area" id="rap-page-area-list">
	
	<div class="col-md-12 col-sm-12 rap-layout-main">
		<div class="row rap-toolbar">
			<button id="rap-btn-close">
				<i class="fa fa-times"></i> 关闭
			</button>
		</div>
		<div class="row">
	<table id="rap-table-list" class="rap-table rap-table-list">
		<thead>
			<tr>
				<th>操作日期</th>
				<th>实际变更日期</th>
				<th>变更原因</th>
				<th>所属物业</th>
				<th>资产名称</th>
				<th>物业总面积(m²)</th>
				<th>资产面积(m²)</th>
				<th>区域</th>
				<th>用途</th>
				<th>状态</th>
				<th>不可出租类型</th>
			</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
		</div>
	</div>
</div>
<script>
//表格列定义
var _tableCols = 	[
{
	data : "beginTs",
	width : "120",
	orderable : false
},
{
	data : "recordDate",
	width : "120",
	orderable : false
},
{
	data : "reason",
	width : "120",
	orderable : false,
	render : function(data, type, full) {
		return RapDataTableUtils.renderStrByLength(data,24);
	}
},
{
	data : null,
	width : "120",
	render : function(data, type, full) {
		var content = data.property==null?"":data.property.theName;
		return RapDataTableUtils.renderStrByLength(content,24);
	},
	orderable : false
},
{
	data : 'theName',
	width : "120",
	render : function(data, type, full) {
		return RapDataTableUtils.renderStrByLength(data,24);
	},
	orderable : false
},
{
	data : null,
	width : "50",
	className :"rap-td-number",
	render:function (data, type, full){
		var content = data.property==null?"":data.property.totalArea;
		return milliFormat(content);
	},
	orderable : false
},
{
	data : 'area',
	width : "50",
	className :"rap-td-number",
	render:milliFormat,
	orderable : false
},
{
	data : 'region',
	width : "50",
	orderable : false,
	render : function(data, type, full) {
		return RapDataUtils.getEnumName("stwy_region", data);
	}
},
{
	data : 'usefor',
	width : "50",
	orderable : false,
	render : function(data, type, full) {
		return RapDataUtils.getEnumName("stwy_usefor", data);
	}
},
{
	data : 'assetState',
	width : "50",
	render : renderState,
	orderable : false
},
{
	data : "canNotRentType",
	className : "center",
	orderable : false,
	render : function(data, type, full) {
		return RapDataUtils.getEnumName("stwy_canNotRentType", data);
	},
	width : "80"
}]
;
function loadHistory(theCode){
	var url='${serviceurl}/query';
	$.ajax({
		url : url,
		data : {"search_EQ_theCode":theCode,
				"orderby":"beginTs@desc"},
		dataType : 'json',
		success : function(data) {
			_tableList.clear();
			_tableList.rows.add(data.records);
			_tableList.draw();
		}
	});
}
function renderState(data, type, full) {
	var stateName = RapDataUtils.getEnumName("stwy_assetStatus", data);
	var color="";
	if("0"==data){
		color="#f13e46";
	}else if("1"==data){
		color="grey";
	}else if("2"==data){
		color="#6FB3E0";
	}else if("3"==data){
		color="#FFC125";
	} 
	stateName = "<span style='background-color:"+color+";font-weight:bold;color:#ffffff;padding:2px 5px;'>"+stateName+"</span>";
	return stateName;
}
$(document).ready(function() {
	var theCode = '${param.theCode}';
	$("#rap-btn-close").click(function() {
		window.parent.$.colorbox.close();
	});
	
	//非服务器分页
	_tableList = $('#rap-table-list').DataTable({
		"columns" : _tableCols,
		"order": [] 
	});
	
	loadHistory(theCode);
});
</script>